// pages/content/singer.js
var startY, endY;
var moveFlag = true; // 判断执行滑动事件
const app=getApp()
let arr=app.globalData.arr
let i=app.globalData.i
let arr2=app.globalData.arr2
let url=app.globalData.url
let data=app.globalData.data
Page({

    /**
     * 页面的初始数据
     */
    data: {
        style1:"title-hover",
        style2:"classify",
        style3:"bord",
        style4:"singer-all",
        love:"+关注",
        lovestyle:"love",
        colour :"black",
        colour2:"black",
        colour3:"black",
        colour4:"black",
        colour5:"black",
        colour6:"black",
        colour7:"black",
        colour8:"black",
        singList2:[{}],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let that=this;

        wx.setNavigationBarTitle({
            title: '歌手分类'  //修改title
            
        }),
        wx.request({
            url:app.globalData.url,
            data:app.globalData.data,
            success:function(res){
                const data = res.data
                that.setData({
                   singList2:data
                })
            }
        })
        
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
    },
    se:function(){
        let that=this
        console.log(app.globalData.data),
        wx.request({
            url:'http://49.233.35.127/Wx/Getsinger/',
            data:app.globalData.data,
            
            success:function(res){
                const data = res.data
                that.setData({
                   singList2:data
                })
            }
        })
    },
    select:function(e){
        if(e.target.id < 6){arr[i]=e.target.id}
        else{arr2[i]=e.target.id}
        let x = arr[0]
        let y=arr2[0]
        console.log(x)
        // function sw(x,y){
        if(x==1){
            
            app.globalData.data.Class = '流行'
            app.globalData.data.Sex = '男'
            
            if(y==8){
               app.globalData.data.Sex = '乐队' 
            }else if(y==7){
                app.globalData.data.Sex = '女'
            }
            this.se()
        }
        else if(x==2){
            app.globalData.data.Class = '摇滚'
            app.globalData.data.Sex = '男'
            if(y==8){
                app.globalData.data.Sex = '乐队' 
            }else if(y==7){
                app.globalData.data.Sex = '女'
            }
            this.se()
        }
        else if(x==3){
            app.globalData.data.Class = '说唱'
            app.globalData.data.Sex = '男'
            if(y==8){
                app.globalData.data.Sex = '乐队' 
            }else if(y==7){
                app.globalData.data.Sex = '女'
            }
            this.se()
        }

        else if(x==4){
            
            app.globalData.data.Class = '民谣'
            app.globalData.data.Sex = '男'
            if(y==8){
                app.globalData.data.Sex = '乐队' 
            }else if(y==7){
                app.globalData.data.Sex = '女'
            }
            this.se()
        }
        else if(x==5){
            app.globalData.data.Class = '其他'
            app.globalData.data.Sex = '男'
            if(y==8){
               app.globalData.data.Sex = '乐队' 
            }else if(y==7){
                app.globalData.data.Sex = '女'
            }
            this.se()
        }



        // }

        if(e.target.id==="1"){

            this.setData({
                colour: "red",
                colour2:"black",
                colour3:"black",
                colour4:"black",
                colour5:"black"
            })
           
        }
        if(e.target.id==="2"){
            this.setData({
                colour: "black",
                colour2:"red",
                colour3:"black",
                colour4:"black",
                colour5:"black",

            })
            
        }
        if(e.target.id==="3"){
            this.setData({
                colour: "black",
                colour2:"black",
                colour3:"red",
                colour4:"black",
                colour5:"black"
            })
        }
        if(e.target.id==="4"){
            this.setData({
                colour: "black",
                colour2:"black",
                colour3:"black",
                colour4:"red",
                colour5:"black"
            })
            
        }
        if(e.target.id==="5"){
            this.setData({
                colour: "black",
                colour2:"black",
                colour3:"black",
                colour4:"black",
                colour5:"red"
            })
            
        }
        if(e.target.id==="6"){
            this.setData({
                colour6:"red",
                colour7: "black",
                colour8: "black"
            })
            
        }
        if(e.target.id==="7"){
            this.setData({
                colour6:"black",
                colour7: "red",
                colour8: "black"
            })
            
        }
        if(e.target.id==="8"){
            this.setData({
                colour6:"black",
                colour7: "black",
                colour8: "red"
            })
            
        }

        


    },
    Love:function(){
        this.setData({
            love:"已关注",
            lovestyle:"love1"
        })
    },
    getclassify:function(){
        this.setData({
            style1:"title-hover",
            style2:"classify",
            style3:"bord",
            style4:"singer-all"
        })
    },


    touchStart: function(e) {
		startY = e.touches[0].pageY; // 获取触摸时的原点
		moveFlag = true;
	},
	// 触摸移动事件
	touchMove: function(e) {
		endY = e.touches[0].pageY; // 获取触摸时的原点
		if (moveFlag) {
			if (endY - startY > 50) {
                this.setData({
                    style1:"title",
                    style2:"classify-hover",
                    style3:"bord-hover",
                    style4:"singer-all-hover"
                })
				moveFlag = false;
			}
			if (startY - endY > 50) {
                this.setData({
                    style1:"title",
                    style2:"classify-hover",
                    style3:"bord-hover",
                    style4:"singer-all-hover"
                })
				moveFlag = false;
            }

		}
	},
	// 触摸结束事件
	touchEnd: function(e) {
		moveFlag = true; // 回复滑动事件
	},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})